package com.singfan.core.dao.database.impl;

import com.singfan.common.db.DaoBaseGeneric;
import com.singfan.core.dao.database.IOrderPayChannelInfoDao;
import com.singfan.core.dao.database.model.OrderPayChannelInfo;
import org.springframework.stereotype.Repository;

/**
 * Author: hansonghe
 * Date: 2015-09-01 17:11
 * Desc:
 */
@Repository
public class OrderPayChannelInfoDaoImpl extends DaoBaseGeneric<OrderPayChannelInfo> implements IOrderPayChannelInfoDao {
    @Override
    protected String getTableName(Object hashKey) {
        return tableNameBase;
    }

    @Override
    protected String getDatabaseId(Object hashKey) {
        return "app_1";
    }

    @Override
    public void create(OrderPayChannelInfo orderPayChannelInfo) {
        insert(orderPayChannelInfo.getOrderId(), orderPayChannelInfo);
    }

    @Override
    public OrderPayChannelInfo selectById(long orderId) {
        String sql = "SELECT * FROM " + getTableName(orderId) + " WHERE order_id=?";
        return selectOne(null, sql, orderId);
    }

    @Override
    public void updateRefund(long orderId, String refundInfo) {
        String sql = "UPDATE " + getTableName(orderId) + " SET refund_content=? WHERE order_id=?";
        execute(orderId, sql, refundInfo, orderId);
    }
}
